fix(data): rewrite bundled Skeleton.hwpx id to fit in signed int32#37
Merged
Merged
Conversation
The bundled skeleton template that seeds HwpxDocument.new() shipped with <hp:p id="3121190098"> in Contents/section0.xml. That value is >= 2^31 and the same out-of-range pattern that downstream consumers misinterpret as a negative signed int. Replacing it with id="0" keeps the template within [0, 2^31) without changing any other content; the rest of the archive (header.xml, settings.xml, etc.) was already in range. Adds a regression test that scans every <name>.xml inside Skeleton.hwpx for id attributes and asserts they all fit in signed int32.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #35.
Root cause
src/hwpx/data/Skeleton.hwpxis the seed used byHwpxDocument.new(). ItsContents/section0.xmlshipped with3121190098=0xBA0994D2, with bit 31 set. Every newly-created document inherits this out-of-range id at its first paragraph, and the_allocate_*_idhelpers (max + 1) propagate the high value into subsequent ids whenever the skeleton paragraph is the current maximum.Fix
Replace the lone out-of-range id with
0. The other ids inside the archive (Contents/header.xml,settings.xml, etc.) were already in range, so a single replacement is enough.The repacked archive keeps the original file order and stores
mimetypefirst / uncompressed, matching the OPC convention used by the existing template.Regression test
tests/test_skeleton_template_ids.py(new):Without the fix, this test fails on the seed file:
With the fix:
Wider regression check
HwpxDocument.new()and the existing template/regression tests all continue to pass.Notes
_paragraph_id/_object_id/_memo_idPR (_paragraph_id/_object_id/_memo_idproduce values that overflow signed 32-bit #34) but does not depend on it; either can land first.